<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% submission_comment ||= nil; show_context ||= false; brief ||= false %>
<% context = submission_comment.context rescue @context %>
<div class="communication_message submission_comment" style="<%= hidden unless submission_comment %>" id="submission_comment_<%= submission_comment ? submission_comment.id : "blank" %>">
  <div class="header">
    <div class="post_date created_at"><%= datetime_string(submission_comment.created_at) rescue nbsp %></div>
    <%= image_tag "grading_icon.png", :class => "topic_icon", :alt => t(:grading_alt, "grading"), :title => t(:submission_comment, "Submission Comment"), :style => brief ? "padding: 2px;" : "" %>
    <a href="<%= context_url(context, :context_assignment_submission_url, submission_comment.submission.assignment_id, submission_comment.submission.user_id) %>" class="title subject"><%= submission_comment.submission.assignment.title rescue t(:assignment, "Assignment") %>, <%= context_user_name(context, submission_comment.submission.user) %></a>
    <a span="padding-left: 10px;" href="<%= context_url(context, :context_user_url, submission_comment ? submission_comment.author_id : '{{ user_id }}') %>" class="user_name"><%= context_user_name(context, submission_comment.author) rescue nbsp %></a>
    <div class="clear"></div>
  </div>
  <div class="content">
    <div style="float: left; margin: 0 5px 0 -10px;"><%= avatar((submission_comment.author_id rescue nil), context.asset_string, 30) %></div>
    <div class="message user_content formatted_body"><%= user_content(submission_comment.try(:formatted_body)) || nbsp %></div>
    <div class="attachments_list" style="margin-top: 5px; <%= hidden unless submission_comment && !submission_comment.attachments.empty? %>">
      <% (submission_comment.attachments rescue []).each do |attachment| %>
        <div class="attachment">
          <a href="<%= context_url(context, :context_assignment_submission_url, submission_comment.submission.assignment_id, submission_comment.submission.user_id, :comment_id => submission_comment.id, :download => attachment.id) %>" class="comment_attachment_link download"> <%= attachment.display_name %> - <%= attachment.readable_size %></a>
        </div>
      <% end %>
    </div>
    <div class="clear"></div>
  </div>
</div>
